include(PurCCommon)

find_package(SQLite3 3.10.0)

set(SQLITE_LIBRARY_TYPE SHARED)

set(SQLITE_PUBLIC_HEADERS
)

set(SQLITE_SOURCES
    sqlite3.c
)

set(SQLITE_PRIVATE_INCLUDE_DIRECTORIES
    "${CMAKE_BINARY_DIR}"
    "${PURC_DIR}"
    "${PURC_DIR}/include"
    "${FORWARDING_HEADERS_DIR}/purc"
    "${PurC_DERIVED_SOURCES_DIR}"
    "${SQLite3_INCLUDE_DIR}"
)

set(SQLITE_LIBRARIES
    ${SQLite3_LIBRARY}
    ${CMAKE_DL_LIBS}
)

link_directories (${CMAKE_BINARY_DIR}/Source/PurC)
list(APPEND SQLITE_LIBRARIES PurC::PurC SQLite::SQLite3)

PURC_FRAMEWORK_DECLARE(SQLITE)
PURC_INCLUDE_CONFIG_FILES_IF_EXISTS()

set_target_properties(SQLITE PROPERTIES OUTPUT_NAME "purc-dvobj-SQLITE")
set_target_properties(SQLITE PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")

PURC_WRAP_SOURCELIST(${SQLITE_SOURCES})
PURC_FRAMEWORK(SQLITE)

install(TARGETS SQLITE DESTINATION "${LIB_INSTALL_DIR}/purc-${PURC_API_VERSION}")

if (MSVC)
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
endif ()
